<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:include page="directive.jsp" />
<c:if test="${empty user.username}">
    <%-- login needed --%>
    <jsp:forward page="login.jsp">
        <jsp:param name="from" value="shipping.jsp"/>
    </jsp:forward>
</c:if>
<c:choose>
    <c:when test="${!empty param.receiverName}">
        <jsp:setProperty name="shipping" property="receiverName" value="${param.receiverName}"/>
        <jsp:setProperty name="shipping" property="receiverPhone" value="${param.receiverPhone}"/>
        <jsp:setProperty name="shipping" property="shippingAddress" value="${param.add1}<br/>${param.add2}<br/>${param.add3}<br/>${param.add4}<br/>${param.add5}<br/>${param.add6}"/>
        <c:choose>
            <c:when test="${param.billAsShip == '1'}">
                <jsp:setProperty name="shipping" property="customerName" value="${param.receiverName}"/>
                <jsp:setProperty name="shipping" property="billingAddress" value="${shipping.shippingAddress}"/>
            </c:when>
            <c:otherwise>
                <jsp:setProperty name="shipping" property="customerName" value="${user.customer.firstname} ${user.customer.lastname}"/>
                <jsp:setProperty name="shipping" property="billingAddress" value="${user.customer.billingAddress}"/>
            </c:otherwise>
        </c:choose>
        <jsp:forward page="checkout.jsp"/>
    </c:when>
    <c:otherwise>
    <jsp:include page="header.jsp" />

	<div id="inner_wrap">
	<div id="inner_hold">
	<div class="wrap_in" style="padding: 15px 1px;">

	<div class="pad_30_both">
		<div class="rgtspn"><div id="secure_badge" title="Secure Online Shopping"></div></div>
		<h1>Shipping &amp; Billing Information</h1>
		<p class="font_small">Step <strong class="red">1</strong> of 2</p>
		<div class="empty"></div>
	</div>


	<form action="shipping.jsp" name="bagform" id="bagform" method="post">
	<div id="frm_bag_in">
	<table width="100%" cellspacing="0" cellpadding="0">
		<tr>
			<td id="frm_inputs">
				<h3 class="doc_email">Your Email Address</h3>
				<div class="mar_25_lft font11_ge frm_sep">
					<div class="mar_25_lft">
					<p><input type="text" value="" class="tinput" style="width: 455px" /></p>
					<p style="padding: 10px 0"><span class="warni">Confirmations will be sent to this <strong>address</strong>. Please double check.</span></p>
					</div>
				</div>
				<div class="spacer"></div>

				<h3>Shipping Address</h3>
				<div class="mar_25_lft frm_sep">

				<div class="mar_25_lft">
				<table width="100%" cellspacing="0" cellpadding="0">
					<tr height="58">
						<td width="55%" valign="top">
							<label for="receiverName">Full Name <span class="font_light">(Name Surname)</span> <span class="red">*</span></label>
							<input type="text" name="receiverName" value="" class="tinput" />
						</td>
						<td width="45%">&nbsp;</td>
					</tr>
					<tr height="58">
						<td width="100%" valign="top">
							<label for="add1">Address Line 1 <span class="red">*</span></label>
							<input type="text" name="add1" value="" class="tinput" />
						</td>
						<td width="45%" valign="top">
							<label for="add2">Address Line 2</label>
							<input type="text" name="add2" value="" class="tinput" />
						</td>
					</tr>
					<tr height="58">
						<td width="55%" valign="top">
							<label for="add3">City<span class="red">*</span></label>
							<input type="text" name="add3" value="" class="tinput" />
						</td>
						<td width="45%" valign="top">
							<label for="add4">Country<span class="red">*</span></label>
							<input type="text" name="add4" value="" class="tinput" />
						</td>
					</tr>
					<tr height="58">
						<td width="55%" valign="top">
							<table width="100%" cellspacing="0" cellpadding="0">
								<tr>
									<td width="120">
										<label for="add5">Zip, Postal Code<span class="red">*</span></label>
										<input type="text" name="add5" value="" class="tinput" style="width: 80px" />
									</td>
									<td>
										<label for="add6">State, Province, Region</label>
										<input type="text" name="add6" value="" class="tinput" style="width: 80px" />
									</td>
								</tr>
							</table>
						</td>
						<td width="45%" valign="top">
							<label for="phone">Phone Number<span class="red">*</span></label>
							<input type="text" name="receiverPhone" value="" class="tinput" />
						</td>
					</tr>
				</table>
				</div>
				</div>

				<h3>Billing Address</h3>
				<div class="mar_25_lft frm_sep " style="padding-top: 10px">
					<div class="warni font11_ge"><input type="radio" value="1" name="billAsShip" checked="checked" /> My <strong>Shipping</strong> and <strong>Billing Addresses</strong> are the same.</div>
					<div class="warni font11_ge"><input type="radio" value="0" name="billAsShip" /> Use <strong>Billing Address</strong> from in my <strong><a href="account.jsp">Account Information</a></strong> instead.</div>
				</div>
				</div>

				<h3 style="background: url(img/doc_ship.gif) no-repeat top left">Shipping Method</h3>
				<div id="shipping_div">
					<p class="font11_ge" style="padding: 10px 0"><span class="warni">Shipping method available <strong>Ground Shipping</strong>.</span></p>
				</div>

				<div class="mar_25_lft frm_sep_up">
					<div id="discount_new_div" class="hidmemty">&nbsp;</div>
					<p class="font11_ge"><span class="warni"><input type="checkbox" value="1" checked="checked" /> Subscribe to newsletter for new products, <strong>SALES</strong> and special offers!</span></p>
				</div>

			</td>
			<td width="50">&nbsp;</td>
			<td width="250" valign="top">
				<div id="dekont">
                    <p class="rgtspn">$<span id="tot_p"><fmt:formatNumber type="number" maxFractionDigits="2" value="${cart.netAmount}"/></span></p>
                    <p style="padding-top: 2px">Subtotal</p>
                    <div class="empty" style="height: 10px"></div>

                    <p class="rgtspn">$<span id="bag_g_ship"><fmt:formatNumber type="number" maxFractionDigits="2" value="${cart.shippingAmount}"/></span></p>
                    <p style="padding-top: 2px">Shipping</p>
                    <div class="empty" style="height: 10px"></div>

                    <p id="discount_tot" class="rgtspn">-$<span id="discount_tot"><fmt:formatNumber type="number" maxFractionDigits="2" value="${cart.discountAmount}"/></span></p>
                    <p style="padding-top: 2px">Discount</p>
                    <div class="empty" style="height: 10px"></div>

                    <p class="rgtspn">$<span id="gift_tot"><fmt:formatNumber type="number" maxFractionDigits="2" value="${cart.taxAmount}"/></span></p>
                    <p style="padding-top: 2px">Tax</p>
                    <div class="empty" style="height: 18px"></div>

                    <p class="rgtspn red" style="font-weight: bold">$<span id="bag_g_tot"><fmt:formatNumber type="number" maxFractionDigits="2" value="${cart.totalAmount}"/></span></p>
                    <p style="padding-top: 2px"><strong>Total</strong></p>
                    <div class="empty"></div>
                </div>
				<div class="font_small_l brdr_thick">* All values, unless otherwise stated, are in <strong>US dollars</strong></div>
			</td>
		</tr>
	</table>
	</div>
	<div id="frm_bag">
        <input type="submit" id="submit" name="checkout" class="but_save_continue" value="Place My Order" />
	</div>
	</form>

	</div>
	</div>
	</div>

<jsp:include page="footer.jsp" />
</c:otherwise>
</c:choose>
